home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MarkToken.h
-
- Contains: A token that contains a set of other tokens
-
- Written by: Andy Nicholas, Greg Anderson, Tom Conrad, Chris Bingham, Georgiann Puckett, John Thompson-Rohrlich
-
- Copyright: © 1994-1995 by Apple Computer, Inc., all rights reserved.
-
- <5> 6/6/95 ga
-
- */
-
- #ifndef MarkToken_h
- #define MarkToken_h
-
- //
- // ProxyToken.h is needed because
- // TProxyToken is the base class of TMarkToken
- //
- #include "ProxyToken.h"
-
- //
- // TAbstractIterator is the base class of TMarkIterator
- //
- #include "AbstractIterator.h"
-
- class AListOf<TAbstractScriptableObject*>;
-
- #define cMarkToken 'mark'
-
- //
- // Needed for a callback in MoreAEM
- //
- TAbstractScriptableObject* MarkTokenMergeProc(TAbstractScriptableObject* baseToken, TAbstractScriptableObject* mergeToken);
-
- //========================================================================================
- //
- // CLASS TMarkToken
- //
- //========================================================================================
-
- class TMarkToken : public TProxyToken
- {
- public:
- DeclareSmallClassData(TMarkToken, TProxyToken);
-
- TMarkToken(TypeOfMarkToken markType) : fMarkList(nil), fIsUnionMark(markType) {};
- TMarkToken(AListOf<TAbstractScriptableObject*>* list, TypeOfMarkToken markType) : fMarkList(list), fIsUnionMark(markType) {};
- virtual ~TMarkToken();
-
- virtual void CloneOwnedObjects();
-
- void IMarkToken();
- void SetUnionMark(TypeOfMarkToken isUnionMark) { fIsUnionMark = isUnionMark; }
- Boolean IsUnionMark() { return (fIsUnionMark == kSingleItemOrUnion) || (fIsUnionMark == kPropertyUnion); }
-
- virtual Boolean DerivedFromOSLClass(const TAETransaction& t, DescType objectClass);
- virtual DescType DefaultType(const TAETransaction& t, DescType propertyName);
- virtual DescType BestType(const TAETransaction& t, DescType propertyName);
-
- virtual TAbstractObjectIterator* DirectObjectIterator(const TAETransaction&);
- virtual TAbstractObjectIterator* ElementIterator(const TAETransaction&);
-
- virtual TAbstractScriptableObject* AdoptToken(TAbstractScriptableObject* token, TypeOfMarkToken);
- virtual void AddThisToMarkToken(TAbstractScriptableObject*& markToken, TypeOfMarkToken);
-
- virtual void AdjustMarks(long newStart, long newStop);
-
- protected:
-
- //
- // fMarkList is a list of all of the tokens designated by the mark token
- //
- AListOf<TAbstractScriptableObject*>* fMarkList;
-
- //
- // fIsUnionMark is true if this mark token was created in order to
- // silently union together multiple hits to a request that is usually
- // matched by a single token (e.g. AccessByName, as in 'folder "Bad Idea"
- // of desktop', when there are two folders named "Bad Idea" on the desktop).
- //
- // Tokens unioned together in this manner will behave as a single
- // container; for example, 'count folder "Bad Idea" of desktop each item' will
- // return the sum of the number of items inside each folder named
- // "Bad idea" on the desktop. This is different than the behavior of
- // non-union mark tokens; for example, 'count every folder of desktop
- // whose name is "Bad Idea" each item' will return the number of
- // folders named "Bad Idea" on the desktop, because 'whose' clauses do
- // not generate union mark tokens.
- //
- // The only variation on behavior is in CaclulateCount and AccessByIndex.
- // I was tempted to make a class TUnionMarkToken : public TMarkToken, but
- // I was unsure if I might need to dynamicly transmogrify a non-union mark
- // into a union mark.
- //
- TypeOfMarkToken fIsUnionMark;
- };
-
-
- class TScriptableObjectListIterator;
-
-
- //========================================================================================
- // Class TMarkTokenIterator
- //========================================================================================
- class TMarkTokenIterator : public TAbstractObjectIterator
- {
- private:
- TScriptableObjectListIterator* fListIter;
- TAbstractObjectIterator* fCurrentIter;
- Boolean fDirection;
-
- AListOf<TAbstractScriptableObject*>* fMarkList;
- Boolean fIterateElements;
- Boolean fRequireExists;
- Boolean fDeleteListOnDestruction;
-
- public:
- TMarkTokenIterator(AListOf<TAbstractScriptableObject*>* markList, Boolean iterateElements, Boolean requireExists, Boolean deleteListOnDestruction = false) :
- fListIter(nil),
- fCurrentIter(nil),
- fDirection(kForwardIteration),
- fMarkList(markList),
- fIterateElements(iterateElements),
- fRequireExists(requireExists),
- fDeleteListOnDestruction(deleteListOnDestruction) { this->Reset(TAETransaction(), kForwardIteration); }
-
- virtual ~TMarkTokenIterator();
-
- //
- // Interface to code to:
- //
- virtual void Reset(const TAETransaction& t, Boolean iterationDirection = kForwardIteration);
- virtual Boolean More(const TAETransaction&) const;
- virtual void Next(const TAETransaction&);
- virtual TAbstractScriptableObject* Current(const TAETransaction&);
-
- virtual void SearchDeep(const TAETransaction& t, TAbstractCollector* collector, DescType desiredClass, TAbstractSearchSpec* searchSpec);
-
- private:
- void SetupCurrentIterator(const TAETransaction& t);
- };
-
-
- #endif
-
-